import requert from "@/utils/request";

// 获取文章列表
export const getArticle = (params) => {
  return requert({
    method: "GET",
    url: "/v1_0/articles",
    params,
  });
};

// 获取文章
export const getArticleById = (ArticleId) => {
  return requert({
    method: "GET",
    url: `/v1_0/articles/${ArticleId}`,
  });
};

// 收藏文章
export const addCollect = (target) => {
  return requert({
    method: "POST",
    url: "/v1_0/article/collections",
    data: {
      target,
    },
  });
};

// 取消收藏文章
export const deleteCollect = (target) => {
  return requert({
    method: "DELETE",
    url: `/v1_0/article/collections/${target}`,
  });
};

// 收藏文章
export const addLike = (target) => {
  return requert({
    method: "POST",
    url: "/v1_0/article/likings",
    data: {
      target,
    },
  });
};

// 取消收藏文章
export const deleteLike = (target) => {
  return requert({
    method: "DELETE",
    url: `/v1_0/article/likings/${target}`,
  });
};
